package DnD;

import partes_GUI.Stats_GUI.StatComponentFactory;
import partes_GUI.Stats_GUI.StatScrollBar;
import partes_GUI.Stats_GUI.StatTF;
import DnD.DnD_Enums.DnD_StatName;

public class DnD_SCF extends StatComponentFactory<DnD_StatName>{

	private class DnD_StatTF extends StatTF{

		private static final long serialVersionUID = 5947510276641625092L;

		public DnD_StatTF(){
			super(30, 20, true);
			this.addKeyListener(null);
		}
		
		public void actualizar() {
			this.setText(ssb.getValue()+"");		
		}
	}
	
	private class DnD_BonusTF extends StatTF{
		
		private static final long serialVersionUID = -5641202801107543146L;

		public DnD_BonusTF(){
			super(30, 20, false);
		}
		
		public void actualizar() {}
		
	}
	private class DnD_ModTF extends StatTF{

		private static final long serialVersionUID = 2660911658103876411L;

		private DnD_BonusTF b;
		
		public DnD_ModTF(DnD_BonusTF b){
			super(30, 20, false);
			this.b=b;
			this.setEnabled(false);
			setText("");
		}

		public void actualizar() {
			int t=ssb.getValue();
			if (!b.getText().equals(""))
				t+=Integer.parseInt(b.getText());
			if (t<10)
				this.setText((t-11)/2+"");
			else this.setText((t-10)/2+"");
		}

	}

	public StatScrollBar crearStatScrollBar() {		
		return new StatScrollBar();
	}

	public StatTF[] crearStatTFs() {
		DnD_BonusTF aux1=new DnD_BonusTF();
		StatTF[] aux={new DnD_StatTF(), aux1, new DnD_ModTF(aux1)};
		return aux;
	}

	public DnD_StatName[] ids() {
		return DnD_StatName.values();
	}

	
}
